#pragma once
#include "DataStructure/Input/Solver/Subcase.h"

#include "DBManager/DBServiceFactory.h"
#include "DBManager/Database/DatabaseFactory.h"
#include "DBManager/IService/Input/Element/IElementService.h"
#include "DBManager/IService/Input/Property/IPRODService.h"
#include "DBManager/IService/Input/Subcase/ISubcaseService.h"
#include "DBManager/Database/DatabaseFactory.h"
#include "DBManager/DBServiceFactory.h"

#include "DBManager/IService/Input/Node/INodeService.h"
#include "DBManager/IService/Input/Element/IElementService.h"

using SG::DataStructure::FEM::DOFDirections;
using namespace SG::DBManager;
using namespace SG::DataStructure::FEM;

/// 杆桁架模型数据
class Quad4_FourQuadDisc
{
  public:
    Quad4_FourQuadDisc ()
    {
      DB_SERVICEFACTORY -> ClearDatabase();
      Input (DB_SERVICEFACTORY);
  }
    /// @brief 写入模型数据
    void               Input (const DBServiceFactorySP m_dbServiceFactory);
    DBServiceFactorySP GetModel ()
    {
        return DB_SERVICEFACTORY;
    }
};

inline void Quad4_FourQuadDisc::Input (DBServiceFactorySP m_dbServiceFactory)
{
    // 节点写入
    NodeData node;
    node.m_id       = 1;
    node.m_x[0]     = 0.0;
    node.m_x[1]     = 0.0;
    node.m_x[2]     = 0.0;
    m_dbServiceFactory->get<INodeService> ()->Add (node);
    node.m_id       = 2;
    node.m_x[0]     = 0.0;
    node.m_x[1]     = 1.0;
    node.m_x[2]     = 0.0;
    m_dbServiceFactory->get<INodeService> ()->Add (node);
    node.m_id       = 3;
    node.m_x[0]     = 1.0;
    node.m_x[1]     = 1.0;
    node.m_x[2]     = 0.0;
    m_dbServiceFactory->get<INodeService> ()->Add (node);
    node.m_id       = 4;
    node.m_x[0]     = 1.0;
    node.m_x[1]     = 0.0;
    node.m_x[2]     = 0.0;
    m_dbServiceFactory->get<INodeService> ()->Add (node);
    node.m_id       = 5;
    node.m_x[0]     = 2.0;
    node.m_x[1]     = 0.0;
    node.m_x[2]     = 0.0;
    m_dbServiceFactory->get<INodeService> ()->Add (node);
    node.m_id       = 6;
    node.m_x[0]     = 2.0;
    node.m_x[1]     = 1.0;
    node.m_x[2]     = 0.0;
    m_dbServiceFactory->get<INodeService> ()->Add (node);
    node.m_id       = 7;
    node.m_x[0]     = 3.0;
    node.m_x[1]     = 1.0;
    node.m_x[2]     = 0.0;
    m_dbServiceFactory->get<INodeService> ()->Add (node);
    node.m_id       = 8;
    node.m_x[0]     = 3.0;
    node.m_x[1]     = 0.0;
    node.m_x[2]     = 0.0;
    m_dbServiceFactory->get<INodeService> ()->Add (node);
    node.m_id       = 9;
    node.m_x[0]     = 4.0;
    node.m_x[1]     = 0.0;
    node.m_x[2]     = 0.0;
    m_dbServiceFactory->get<INodeService> ()->Add (node);
    node.m_id       = 10;
    node.m_x[0]     = 4.0;
    node.m_x[1]     = 1.0;
    node.m_x[2]     = 0.0;
    m_dbServiceFactory->get<INodeService> ()->Add (node);

    // 单元写入
    SG::DataStructure::FEM::CQUAD4Data CQUAD4;
    CQUAD4.m_id   = 1;
    CQUAD4.m_pId  = 1;
    CQUAD4.m_g[0] = 1;
    CQUAD4.m_g[1] = 2;
    CQUAD4.m_g[2] = 3;
    CQUAD4.m_g[3] = 4;
    m_dbServiceFactory->get<IElementService> ()->Add (CQUAD4);
    CQUAD4.m_id   = 76;
    CQUAD4.m_pId  = 1;
    CQUAD4.m_g[0] = 3;
    CQUAD4.m_g[1] = 4;
    CQUAD4.m_g[2] = 5;
    CQUAD4.m_g[3] = 6;
    m_dbServiceFactory->get<IElementService> ()->Add (CQUAD4);
    CQUAD4.m_id   = 34;
    CQUAD4.m_pId  = 1;
    CQUAD4.m_g[0] = 5;
    CQUAD4.m_g[1] = 6;
    CQUAD4.m_g[2] = 7;
    CQUAD4.m_g[3] = 8;
    m_dbServiceFactory->get<IElementService> ()->Add (CQUAD4);
    CQUAD4.m_id   = 2;
    CQUAD4.m_pId  = 1;
    CQUAD4.m_g[0] = 7;
    CQUAD4.m_g[1] = 8;
    CQUAD4.m_g[2] = 9;
    CQUAD4.m_g[3] = 10;
    m_dbServiceFactory->get<IElementService> ()->Add (CQUAD4);
}